package nathan.qq.groupfriend;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import net.mindview.util.TextFile;

public class GroupFirendExport {

	public static void main(String[] args) {
		System.out.println(System.getProperty("user.dir"));

		Set<String> friends = new HashSet<String>();
		TextFile tf = new TextFile(
				TextFile.getFilePathUseClasspath("/nathan/qq/groupfriend/friends.txt"));
		for (String s : tf) {
			if (s.startsWith("消息对象")) {
				friends.add(s.substring(s.indexOf(":") + 1).trim());
			}
		}
		List<String> list = new ArrayList<String>(friends);
		Collections.sort(list);

		exportHtmlFile(list);

	}

	private static void exportHtmlFile(Collection<String> friends) {
		String html = "<html><body><table border='1'>";
		for (String s : friends) {
			html += ("<tr><td>" + s + "</td></tr>");
		}
		html += "</table></body></html>";
		TextFile.write(System.getProperty("user.dir") + "\\friends.html", html);
	}

}
